﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using KPIS.GERP.GIMS.BLL;
using KPIS.GERP.GIMS.IBLL;
using KPIS.GERP.GIMS.MODEL;
using System.Data;

namespace KPIS.GERP.GIMS.APP.APP_UI.UserControl
{
    public partial class TIP_Approve_Detail : System.Web.UI.UserControl
    {
        private string ref_no;
        private string DisType;
        private ProgressPrePurchaseRequestBLL bllPpr = new ProgressPrePurchaseRequestBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            ref_no = Session["RefNo"].ToString();
            DisType = Session["DisType"].ToString();
            ShowDisplay(DisType);
        }

        protected void ShowDisplay(string DisType)
        {
            if (DisType == "prr")
            {
                LoadPurchaseRequestRoute();
            }
            else if (DisType == "br")
            {
                LoadBidRoute();
            }
            else if (DisType == "por")
            {
                LoadPurhaseOrderRoute();
            }
            else if (DisType == "dnr")
            {
                LoadDeliveryNoteRoute();
            }
        }

        protected void LoadPurchaseRequestRoute()
        {
            IList<PrePurchaseRequestRouteInfo> InfoPprRoute = bllPpr.GetPrePurchaseRequestRoute(1);
            GridDetail.DataSource = InfoPprRoute;

            GridBoundColumn myColumn = (GridBoundColumn)GridDetail.Columns[0];
            myColumn.DataField = "Order";
            myColumn.UniqueName = "Order";

            myColumn = (GridBoundColumn)GridDetail.Columns[1];
            myColumn.DataField = "InfoFromEmp.Name";
            myColumn.UniqueName = "InfoFromEmp.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[2];
            myColumn.DataField = "InfoToEmp.Name";
            myColumn.UniqueName = "InfoToEmp.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[3];
            myColumn.DataField = "InfoRouteStatus.Name";
            myColumn.UniqueName = "InfoRouteStatus.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[4];
            myColumn.DataField = "Remark";
            myColumn.UniqueName = "Remark";

            GridDetail.DataBind();
        }

        protected void LoadBidRoute()
        {
            IList<BidRouteInfo> InfoBidRoute = bllPpr.GetBidRoute(1);
            GridDetail.DataSource = InfoBidRoute;

            GridBoundColumn myColumn = (GridBoundColumn)GridDetail.Columns[0];
            myColumn.DataField = "Order";
            myColumn.UniqueName = "Order";

            myColumn = (GridBoundColumn)GridDetail.Columns[1];
            myColumn.DataField = "InfoFromEmp.Name";
            myColumn.UniqueName = "InfoFromEmp.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[2];
            myColumn.DataField = "InfoToEmp.Name";
            myColumn.UniqueName = "InfoToEmp.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[3];
            myColumn.DataField = "InfoRouteStatus.Name";
            myColumn.UniqueName = "InfoRouteStatus.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[4];
            myColumn.DataField = "Remark";
            myColumn.UniqueName = "Remark";

            GridDetail.DataBind();
        }

        protected void LoadPurhaseOrderRoute()
        {
            IList<PurchaseOrderRouteInfo> InfoPurOrder = bllPpr.GetPurchaseOrderRoute(1);
            GridDetail.DataSource = InfoPurOrder;

            GridBoundColumn myColumn = (GridBoundColumn)GridDetail.Columns[0];
            myColumn.DataField = "Order";
            myColumn.UniqueName = "Order";

            myColumn = (GridBoundColumn)GridDetail.Columns[1];
            myColumn.DataField = "InfoFromEmp.Name";
            myColumn.UniqueName = "InfoFromEmp.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[2];
            myColumn.DataField = "InfoToEmp.Name";
            myColumn.UniqueName = "InfoToEmp.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[3];
            myColumn.DataField = "InfoRouteStatus.Name";
            myColumn.UniqueName = "InfoRouteStatus.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[4];
            myColumn.DataField = "Remark";
            myColumn.UniqueName = "Remark";

            GridDetail.DataBind();
        }

        protected void LoadDeliveryNoteRoute()
        {
            IList<DeliveryNoteRouteInfo> InfoPurOrder = bllPpr.GetDeliveryNoteRoute(1);
            GridDetail.DataSource = InfoPurOrder;

            GridBoundColumn myColumn = (GridBoundColumn)GridDetail.Columns[0];
            myColumn.DataField = "Order";
            myColumn.UniqueName = "Order";

            myColumn = (GridBoundColumn)GridDetail.Columns[1];
            myColumn.DataField = "InfoFromEmp.Name";
            myColumn.UniqueName = "InfoFromEmp.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[2];
            myColumn.DataField = "InfoToEmp.Name";
            myColumn.UniqueName = "InfoToEmp.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[3];
            myColumn.DataField = "InfoRouteStatus.Name";
            myColumn.UniqueName = "InfoRouteStatus.Name";

            myColumn = (GridBoundColumn)GridDetail.Columns[4];
            myColumn.DataField = "Remark";
            myColumn.UniqueName = "Remark";

            GridDetail.DataBind();
        }

        protected void GridDetail_ItemCommand(object source, GridCommandEventArgs e)
        {

        }
    }
}